﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using SnowDAL;

namespace Snow
{
    public partial class UserList : System.Web.UI.Page
    {
        private Hashtable _where = new Hashtable();

        private UserDAL _dal = new UserDAL();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected Hashtable QuerySetting()
        {
            if (!String.IsNullOrEmpty(txtUid.Text.Trim()))
                _where.Add("Uid", txtUid.Text.Trim());

            if (!String.IsNullOrEmpty(txtLoginName.Text.Trim()))
                _where.Add("LoginName", txtLoginName.Text.Trim());

            if (!String.IsNullOrEmpty(txtName.Text.Trim()))
                _where.Add("Name", txtName.Text.Trim());

            //if (!(chkMale.Checked&&chkFemale.Checked)||(!chkMale.Checked&&!chkFemale.Checked))
            //    _where.Add("Sex", chkMale.Checked?"M":"F");

            if (chkMale.Checked && !chkFemale.Checked)
                _where.Add("Sex", "M");

            if (!chkMale.Checked && chkFemale.Checked)
                _where.Add("Sex", "F");

            if (rdoDate.SelectedValue != "NONE")
                _where.Add("Date", rdoDate.SelectedValue);

            if (!chkWei.Checked)
                _where.Add("Wei", "Wei");

            return _where;
        }

        protected void DataBindGridView()
        {
            this.GridView1.DataSource = _dal.QueryUserInfo(QuerySetting());
            this.GridView1.DataBind();
        }

        protected void btmQuery_Click(object sender, EventArgs e)
        {
            DataBindGridView();
        }

    }
}